package ruxi.tema1;

import java.util.ArrayList;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class CityAdapter extends BaseAdapter {

	private Activity context;
	ArrayList<String> orase;
	
	

	public CityAdapter(Activity _context) {
		super();
		this.context = _context;
		this.orase = new ArrayList<String>();
	}

	@Override
	public int getCount() {
		return orase.size();
	}
	@Override
	public Object getItem(int pos) {
		return orase.get(pos);
	}

	@Override
	public long getItemId(int arg0) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup list) {
		View element;
		 if (convertView == null)
         {
	         LayoutInflater inflater = context.getLayoutInflater();
	         element = inflater.inflate(R.layout.cityview, null);
         }
         else 
        	 element = convertView;
		 
		ImageView cityImg = (ImageView) element.findViewById(R.id.cityimg);
		cityImg.setImageResource(R.drawable.mycity);
		TextView mycity = (TextView) element.findViewById(R.id.mycity);
		mycity.setText(orase.get(position));
		return element;
	}

}
